﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using GomMinhLongDO;
using GomMinhLongBL;

namespace GomMinhLong.Module
{
    public partial class ucDanhMuc : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            rptParent.DataSource = new DataView(new cmsLoaiSanPhamBL().SelectAll(0), "ParentID=0", "OrderID ASC", DataViewRowState.CurrentRows);
            rptParent.DataBind();
        }
        public string FriendlyUrl(string strTitle)
        {
            return Ultility.Change_AV(strTitle);
        }
        public string ReturnShowHide(string idshowhide)
        {
            int i = int.Parse(idshowhide);
            if (Request.QueryString["ID"] != null)
            {
                string url = Request.Url.AbsolutePath;
                url = url.Substring(1, url.Length - 1);
                string url1 = url.Replace(".", "/");
                string Module = url1.Substring(0, url1.IndexOf("/"));
                if (Module.Equals("SanPham"))
                {
                    string id = Request.QueryString["ID"].ToString();
                    if (id.Equals(i.ToString())) return "show-div";
                    else
                    {
                        cmsLoaiSanPhamDO obj = new cmsLoaiSanPhamDO { LoaiSanPhamID = int.Parse(id) };
                        obj = new cmsLoaiSanPhamBL().Select(obj);
                        if (obj.ParentID == i) return "show-div";
                        else return "hide-div";
                    }
                }
                return "hide-div";
            }
            return "hide-div";
        }
        protected void rptParent_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;
            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView drv = (DataRowView)item.DataItem;


                DataTable dtMenuChild = new cmsLoaiSanPhamBL().SelectByParent(int.Parse(drv["LoaiSanPhamID"].ToString()));


                Repeater rptMenuChild = (Repeater)item.FindControl("rptChild");
                rptMenuChild.DataSource = dtMenuChild;
                rptMenuChild.DataBind();


            }
        }
    }
}